#@layout()

#define content()

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:true">
        #include("/common/sa_menus.html")
    </div>
    <div data-options="region:'center',border:true">
        <div id="datagridId"></div>

        <div id="datagridTb">
            <div class="row">
                <div class="col-md-12">
                    <form id="searchForm">
                        <div class="easyui-panel" title="信息查询" style="width:100%;padding:10px;"
                             data-options="iconCls:'icon-application_form'">

                            中文名称: <input class="easyui-textbox" id="configCNameQuery"
                                         data-options="validType:{length:[0,100]}"
                                         style="width:200px">&nbsp;&nbsp;


                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="datagridQuery();" iconCls="icon-zoom">#(_res.get('system.common.search'))</a>
                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="$('#searchForm').form('clear');" iconCls="icon-zoom_out">#(_res.get('system.common.clear'))</a>
                        </div>
                    </form>
                </div>
                <div class="row">
                    <div class="col-md-12" style="padding: 5px 25px;">
                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-pill_add',plain:true" id='uasconfig_add'>增加配置</a>
                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-pill_go',plain:true" id='uasconfig_edit'>编辑配置</a>
                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-pill_delete',plain:true" id='uasconfig_remove'>移除配置</a>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>

#end


#define css()

#end


#define js()

<script type="text/javascript">
    var _datagrid = "datagridId", _form = "formId", _datagridTb = "datagridTb";
    var datagridListUrl = contextRootPath + '/uasConfig/list';

    $(function () {

        //初始化表格
        $("#" + _datagrid).datagrid({
            url: datagridListUrl,
            fit: true,
            border: false,
            rownumbers: true,
            pageSize: 30,
            toolbar: '#' + _datagridTb,
            singleSelect: false,
            pagination: true,
            nowrap: false,
            striped: true,
            fitColumns: true,
            columns: [[
                {
                    field: DBConts.TABLE_UAS_CONFIG.CONFIG_ID,
                    title: DBConts.TABLE_UAS_CONFIG.CONFIG_ID,
                    checkbox: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.CONFIG_CNAME,
                    title: "中文名称",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.CONFIG_ENAME,
                    title: "英文名称",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.CONFIG_TYPE,
                    title: "配置类型",
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value === 2) {
                            return "缓存配置";
                        } else {
                            return "系统设置";
                        }
                    }
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.CONFIG_VALUE,
                    title: "内容",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.CONFIG_USER_DEFINED,
                    title: "是否显示",
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value !== 1) {
                            return "隐藏";
                        } else {
                            return "显示";
                        }
                    }
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.CONFIG_DEFAULT_VALUE,
                    title: "默认值",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.DATA_TYPE,
                    title: "数据类型",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.REGEX,
                    title: "正则表达式",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.ERROR_MSG,
                    title: "错误提示",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_UAS_CONFIG.ORDER_NUMBER,
                    title: "排序",
                    sortable: true
                },
                {
                    field: 'createts',
                    title: "#(_res.get('facet.form.creates'))",
                    sortable: true
                }
                ,
                {
                    field: 'updatets',
                    title: "更新时间",
                    sortable: true
                }
            ]]
        });


        $("#uasconfig_add").on('click', function () {
            var params = {};
            params.title = "增加配置";
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.iconCls = 'icon-application_add';
            params.url = contextRootPath + '/uasConfig/add';
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    datagrid_save('add');
                }
            }, {
                text: '重置',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    clearForm('formId')
                }
            }];

            crud_dlg(params);
        });

        $("#uasconfig_edit").on('click', function () {

            var selected = $('#' + _datagrid).datagrid('getSelected');


            if (selected == null) {
                $.messager.alert("提示框", "请选择需要操作的配置!", "warning");
                return;
            }

            var selections = $('#' + _datagrid).datagrid('getSelections');

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的配置!", "warning");
                return;
            } else if (selections.length > 1) {
                $.messager.alert("提示框", "编辑的配置为多个，请重新选择!", "warning");
                return;
            }

            var params = {};
            params.title = "编辑配置";
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.iconCls = 'icon-application_edit';
            params.url = contextRootPath + '/uasConfig/edit/' + selected[DBConts.TABLE_UAS_CONFIG.CONFIG_ID];
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    datagrid_save('edit');
                }
            }, {
                text: '重置',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    clearForm('formId')
                }
            }];

            crud_dlg(params);
        });


        $("#uasconfig_remove").on('click', function () {
            var selections = $('#' + _datagrid).datagrid('getSelections');
            var ids = "";

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的配置!", "warning");
                return;
            }

            $.messager.confirm('确认框', '请确定需要删除所选择的配置么？', function (r) {
                if (r) {
                    $.each(selections, function (i, v) {
                        ids += v[DBConts.TABLE_UAS_CONFIG.CONFIG_ID] + ",";
                    });

                    $.post(contextRootPath + "/uasConfig/remove/" + ids, function (data) {
                        var params = {};
                        params.element = _datagrid;
                        params.data = data;
                        params.isClose = false;
                        resultCallback(params);
                    }, 'json');
                }
            });


        });
    });


    function datagridQuery() {
        var configCName = $("#configCNameQuery");

        var flag = $("#searchForm").form('enableValidation').form('validate');

        if (!flag) return;

        $("#" + _datagrid).datagrid({
            queryParams: {
                "uasConfig.config_cname": configCName.val()
            }
        });
    }
</script>

#end



